# compile macro
CC	= gcc
AR	= ar
CFLAGS	= -Wall
LDFLAGS	= -lm
INCLUDES= -I/usr/local/include

VPATH   = lib 

# user modify: target and objects
TARGET = test
OBJDIR = obj

SOURCE = $(wildcard *.c) $(notdir $(wildcard lib/*.c))
OBJECTS = $(SOURCE:%.c=$(OBJDIR)/%.o)
#OBJECTS	= main.o algo.o

# make target
all:${OBJECTS}
	${CC} -o ${TARGET} $^ ${LDFLAGS} ${INCLUDES}
# make clean
clean:
	rm -rf ${TARGET} ${OBJECTS} ${OBJDIR}

# dependence	
$(OBJECTS): $(OBJDIR)/%.o : %.c
	@mkdir -p $(OBJDIR)
	$(CC) -c $< -o $@
#%.o : %.c
#	${CC} ${CFLAGS} ${INCLUDES} -c $< -o $@
